import React, { FC, memo } from 'react';
import { isEmpty } from 'project-libs';
import { Empty, LoadMore } from '@/components';
import { IOrderItemProps } from '@/interface';
import Item from '../Item';

interface IListProps {
  orders: IOrderItemProps[];
  type: number | string;
  showMore: boolean;
}

const List: FC<IListProps> = props => {
  const { orders, type, showMore } = props;

  return (
    <div className="lists-wrap">
      {isEmpty(orders) ? (
        <Empty />
      ) : (
        <div className="lists-box">
          {orders.map((item, index) => (
            <Item type={type} key={`${item.id}${index}`} {...item} />
          ))}
          <LoadMore show={showMore} />
        </div>
      )}
    </div>
  );
};

export default memo(List);
